package com.rockxin.cat.activity;

import android.content.Intent;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.rockxin.cat.R;
import com.rockxin.cat.base.BaseActivity;

import butterknife.BindView;

/**
 * Created by cat on 18-3-7.
 */

public class HtmlLocalActivity extends BaseActivity {

    @BindView(R.id.back_img)
    ImageView backImg;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.webView)
    WebView webView;

    @Override
    protected int setLayout() {
        return R.layout.activity_html_local;
    }

    @Override
    public void initData() {
        initView();
        setListener();
    }

    public void initView() {
        title.setText("风险提示");
        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);

        Intent getIntent = getIntent();
        String type = getIntent.getStringExtra("type");
        if(type.equals("registerAgreement")){
            webView.loadUrl("file:///android_asset/register_agreement.html");
        }else if(type.equals("riskHints")){
            webView.loadUrl("file:///android_asset/risk_hints.html");
        }
        else if(type.equals("html5")){
            title.setText(getIntent.getStringExtra("urlname"));
            webView.loadUrl(getIntent.getStringExtra("url"));
        }
    }

    private void setListener() {
        backImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }

}
